//
//  WoyaogentouViewController.m
//  YSZC
//
//  Created by 张斌 on 16/4/14.
//  Copyright © 2016年 YueShiKeJi. All rights reserved.
//

#import "WoyaogentouViewController.h"
#import "LoadVcManager.h"
#import "YSDoViewManager.h"


@interface WoyaogentouViewController ()
@property (weak, nonatomic) IBOutlet UIButton *chongzhi;
@property (weak, nonatomic) IBOutlet UIButton *gentou;

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *imgheight;
@end

@implementation WoyaogentouViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"我要投钱";

    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(changeViewFrame:) name:UIKeyboardWillChangeFrameNotification object:nil];
    
    self.imgheight.constant = [UIScreen mainScreen].bounds.size.height*128/600;
}
- (IBAction)leftbuttonclick:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}
- (IBAction)gentoubtnclick:(id)sender {
    
    // 判断  跳转
    if (0) {
        
    }else{
        
        [self.navigationController pushViewController:[LoadVcManager sbVCWithsbname:@"GentouweiwanshanViewController"] animated:YES];
    }
}


- (void)viewDidLayoutSubviews{
    [super viewDidLayoutSubviews];

    [[YSDoViewManager sharedmanager ] settoyuanWithview:@[self.chongzhi,self.gentou]];
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    
    [self.view endEditing:YES];
}

-(void)changeViewFrame:(NSNotification *)noti{
    //1.获取 结束时候的Frame即可
    //    NSLog(@"%@",noti);
    //2.获取结束的Frame
    CGRect endRect =  [noti.userInfo[@"UIKeyboardFrameEndUserInfoKey"]CGRectValue];
    //拿 结束的Frame中的y值 跟界面的高度做减法 得到 最终 控制器的View 的y值
    CGFloat endY = endRect.origin.y-self.view.frame.size.height+130;
    
    //设置给控制器的View的Frame即可
    CGRect oldFrame=self.view.frame;
    if (endY>0) {
        endY = 0;
    }
    oldFrame.origin.y=endY;
    
    
    self.view.frame=oldFrame;
}
@end
